package cardwall.client.view;

import com.google.gwt.user.client.ui.*;
import cardwall.shared.Task;

/**
 * @author $LastChangedBy: vogensen $
 * @version $Revision: 2 $
 */
public class CardPanel extends FocusPanel {

    private static final String CSS_CARDPANEL = "cardpanel";
    private static final String CSS_DESCRIPTIONTEXT = "descriptiontext";
    private static final String CSS_CARDPANEL_SELECTED = "cardpanel-selected";

    private Task task;

    private boolean selected;

    public CardPanel(final Task task) {
        this.task = task;
        setStyleName(CSS_CARDPANEL);
        setHeight("100px");
        DockPanel panel = new DockPanel();
        add(panel);
        panel.setSize("100%", "100%");
        panel.add(new Label(task.getName()), DockPanel.NORTH);

        Label descriptionLabel = new Label(task.getDescription());
        descriptionLabel.addStyleName(CSS_DESCRIPTIONTEXT);
        panel.add(descriptionLabel, DockPanel.CENTER);
        panel.setCellHeight(descriptionLabel, "100%");
    }

    public Task getTask() {
        return task;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
        if(selected) {
            addStyleName(CSS_CARDPANEL_SELECTED);
        } else {
            removeStyleName(CSS_CARDPANEL_SELECTED);
        }
    }

    public boolean getSelected() {
        return selected;
    }
}
